package com.cndw.kungfu.model.pve.domain;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.ext.XmlProcesser;

public class UnionPetConfig {
	
	private int level;
	private int openNeedRes;
	private int openNeedAsset;
	private int upNeedRes;
	private int upNeedAsset;
	private int achive;

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getOpenNeedRes() {
		return openNeedRes;
	}

	public void setOpenNeedRes(int openNeedRes) {
		this.openNeedRes = openNeedRes;
	}

	public int getOpenNeedAsset() {
		return openNeedAsset;
	}

	public void setOpenNeedAsset(int openNeedAsset) {
		this.openNeedAsset = openNeedAsset;
	}

	public int getUpNeedRes() {
		return upNeedRes;
	}

	public void setUpNeedRes(int upNeedRes) {
		this.upNeedRes = upNeedRes;
	}

	public int getUpNeedAsset() {
		return upNeedAsset;
	}

	public void setUpNeedAsset(int upNeedAsset) {
		this.upNeedAsset = upNeedAsset;
	}

	public int getAchive() {
		return achive;
	}

	public void setAchive(int achive) {
		this.achive = achive;
	}

	public static String getConfigfile() {
		return configFile;
	}

	public static Map<Integer, UnionPetConfig> getConfigmap() {
		return configMap;
	}

	private static final String configFile = "unionPet.xml";

	private static final Map<Integer, UnionPetConfig> configMap = new ConcurrentHashMap<Integer, UnionPetConfig>();

	static {
		load();
	}

	public static synchronized void load() {
		String fileName = ConstantsConfig.getLocaleResource() + configFile;
		List<UnionPetConfig> configList = XmlProcesser.processXml(UnionPetConfig.class, fileName);
		for (UnionPetConfig e : configList) {
			configMap.put(e.getLevel(), e);
		}
	}
	
	public static UnionPetConfig getOne(int level) {
		return configMap.get(level);
	}
	
}
